package com.cn.goodsadmin.common.Lock;

public class CountLockManager {

    private static volatile CountLockManager countLockManager;
    //订单lock
    private CountLock orderCount;
    //咖啡卡卷lock
    private CountLock coffeeCount;
    //打折卡卷
    private CountLock disCardCount;
    //制作咖啡唯一锁
    private CountLock coffeeDoCount;

    private final static byte[] lock = new byte[0];

    public static CountLockManager getIntanceCountLockManager() {
        if (countLockManager == null) {
            synchronized (lock) {
                if (countLockManager == null) {
                    countLockManager = new CountLockManager();
                }
            }
        }
        return countLockManager;
    }

    private CountLockManager() {
        orderCount = new CountLock();
        coffeeCount = new CountLock();
        disCardCount = new CountLock();
        coffeeDoCount=new CountLock();
    }

    public CountLock getCoffeeDoCount() {
        return coffeeDoCount;
    }

    /**
     * 初始化
     *
     * @param ordernumber
     * @param coffeenumber
     * @param discardnumber
     */
    public void init(int ordernumber, int coffeenumber, int discardnumber,int coffeedonumber) {
        orderCount.set(ordernumber);
        coffeeCount.set(coffeenumber);
        disCardCount.set(discardnumber);
        coffeeDoCount.set(coffeedonumber);

    }

    public CountLock getOrderCount() {
        return orderCount;
    }


    public CountLock getCoffeeCount() {
        return coffeeCount;
    }


    public CountLock getDisCardCount() {
        return disCardCount;
    }


}
